package com.lemon.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class PutExtraSecondActivity extends AppCompatActivity {

    EditText editText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_put_extra_second);

        editText = findViewById(R.id.edit_zhen);

        // 展示正向传值
        Intent intent = getIntent();
        String string = intent.getStringExtra("string");
        editText.setText(string);
    }


    // 反向传值
    public void onToastButtonClicked(View v) {
        switch (v.getId()) {
            case R.id.button_put_extra_fan:
                Intent intent = new Intent();
                intent.putExtra("fan",editText.getText().toString());
                setResult(RESULT_OK,intent);
                finish();
                break;
        }
    }

    // 重写返回键盘
    @Override
    public void onBackPressed() {
        Intent intent = new Intent();
        intent.putExtra("fan",editText.getText().toString());
        setResult(RESULT_OK,intent);
        finish();
    }
}
